using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class WF_NotificationMap : EntityTypeConfiguration<WF_Notification>
    {
        public WF_NotificationMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Subject)
                .HasMaxLength(100);

            this.Property(t => t.Priority)
                .IsFixedLength()
                .HasMaxLength(1);

            this.Property(t => t.Status)
                .IsFixedLength()
                .HasMaxLength(1);

            this.Property(t => t.RecordID)
                .HasMaxLength(20);

            this.Property(t => t.Action)
                .HasMaxLength(20);

            this.Property(t => t.Response)
                .IsFixedLength()
                .HasMaxLength(1);

            this.Property(t => t.Request)
                .IsFixedLength()
                .HasMaxLength(2);

            this.Property(t => t.ReplyAction)
                .HasMaxLength(20);

            this.Property(t => t.ReplyRecordID)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("WF_Notification");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.From).HasColumnName("From");
            this.Property(t => t.ToRole).HasColumnName("ToRole");
            this.Property(t => t.ToUser).HasColumnName("ToUser");
            this.Property(t => t.Subject).HasColumnName("Subject");
            this.Property(t => t.Sent).HasColumnName("Sent");
            this.Property(t => t.Due).HasColumnName("Due");
            this.Property(t => t.Note).HasColumnName("Note");
            this.Property(t => t.Priority).HasColumnName("Priority");
            this.Property(t => t.Workflow).HasColumnName("Workflow");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.RecordType).HasColumnName("RecordType");
            this.Property(t => t.RecordID).HasColumnName("RecordID");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.ReplyFrom).HasColumnName("ReplyFrom");
            this.Property(t => t.ReplySent).HasColumnName("ReplySent");
            this.Property(t => t.ReplyNote).HasColumnName("ReplyNote");
            this.Property(t => t.Action).HasColumnName("Action");
            this.Property(t => t.Response).HasColumnName("Response");
            this.Property(t => t.Request).HasColumnName("Request");
            this.Property(t => t.ReplyAction).HasColumnName("ReplyAction");
            this.Property(t => t.ReplyRecordType).HasColumnName("ReplyRecordType");
            this.Property(t => t.ReplyRecordID).HasColumnName("ReplyRecordID");
            this.Property(t => t.Step).HasColumnName("Step");
            this.Property(t => t.MultNoti).HasColumnName("MultNoti");
            this.Property(t => t.OriginNoti).HasColumnName("OriginNoti");

            // Relationships
            this.HasOptional(t => t.Name)
                .WithMany(t => t.WF_Notification)
                .HasForeignKey(d => d.From);
            this.HasOptional(t => t.WF_Step)
                .WithMany(t => t.WF_Notification)
                .HasForeignKey(d => d.Step);
            this.HasRequired(t => t.WF_Workflow)
                .WithMany(t => t.WF_Notification)
                .HasForeignKey(d => d.Workflow);

        }
    }
}
